Skip to content

Cape Town| 25-SDC-July | Faith Muzondo | Sprint 1 | Individual Shells tools #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Faithy4444
Copy link

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

@Faithy4444 Faithy4444 added the Needs Review Participant to add when requesting review label Jul 15, 2025
@OracPrime OracPrime added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Jul 19, 2025
Copy link

@OracPrime OracPrime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there! Couple of minor fixes required, along with a general issue that your scripts should work run from the folder they are saved in. So you sometimes need to change things to use relative paths.

@@ -5,3 +5,5 @@ set -euo pipefail
# TODO: Write a command to output just the names of each player in London along with the score from their last attempt.
# Your output should contain 3 lines, each with one word and one number on it.
# The first line should be "Ahmed 4".

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost. Your code is giving each player's second score. However the question asks for the last score. Leila only has one score, so you need something slightly different.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made changes

@@ -4,3 +4,5 @@ set -euo pipefail

# TODO: Write a command to output the contents of the helper-1.txt file inside the helper-files directory to the terminal.
# The output of this command should be "Once upon a time...".

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sh file could work if it were run in the helper-files directory. However if I run it from here (the cat folder) it doesn't work. How would you make it work from here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it. it now runs from the cat directory, may you please chack it for me

@@ -11,3 +11,5 @@ set -euo pipefail
# It looked delicious.
# I was tempted to take a bite of it.
# But this seemed like a bad idea...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, this would work if run from the right folder, but in general it's best to make sh files run from where they are in the checkout structure, or from a clearly defined location identified in a comment in the file (e.g. Module-Tools).

@@ -9,3 +9,6 @@ set -euo pipefail
# 1 It looked delicious.
# 2 I was tempted to take a bite of it.
# 3 But this seemed like a bad idea...


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs the same relative path fix as the previous two comments, but otherwise looks good

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i fixed it

@@ -4,3 +4,7 @@ set -euo pipefail

# TODO: Write a command to output, for each `.txt` file in this directory, how many lines of dialogue the Doctor has.
# The output should show that dialogue.txt contains 6 lines, dialogue-2.txt contains 2, and dialogue-3.txt contains 0.

for FILE in *.txt; do
grep -c "^Doctor" $FILE

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a very subtle problem with this. Hints:

  1. What does set -euo pipefail do?
  2. What does grep -c return when there are no matches?

That's quite subtle!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also a simpler way to do this without a for loop!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the set -euo pipefail is just for good practice. the e is to ensure the script exists immediately if a command fails, the u causes the script to exit immediately if you try to use an unset variable and the o catches errors in a pipeline. I tried the other way under the original. It is a lot easier, thank you

@@ -8,3 +8,5 @@ set -euo pipefail
# The output should contain 11 lines.
# Line 3 should be "It contains many lines, and there are some things you may want to do with each of them.".
# Line 11 should be "We also should remember, when we go shopping, to get 4 items: oranges, cheese, bread, olives.".

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done, perfect score for sed

@@ -4,3 +4,4 @@ set -euo pipefail

# TODO: Write a command to output the number of words in the file helper-files/helper-3.txt.
# The output should include the number 19. The output should not include the number 92.
wc -w < helper-files/helper-3.txt

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has the same relative path problem we had in cat, but is otherwise correct

@OracPrime OracPrime added Reviewed Volunteer to add when completing a review and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. Needs Review Participant to add when requesting review labels Jul 19, 2025
Copy link

@OracPrime OracPrime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, that all looks good to me, well done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reviewed Volunteer to add when completing a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants